package com.loopy.cookie;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;

public class ReadCookies extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("ReadCookies被调用");
        Cookie[] cookies = request.getCookies();
        if(cookies!=null&&cookies.length!=0){
            for (Cookie cookie : cookies) {
                System.out.println("cookieName="+cookie.getName()+"   cookieValue="+cookie.getValue());
            }
        }
        
    }
}
